require'src.guiutils'
require'src.world'
require'src.entity'

Game = class('Game'):include(Stateful)

function Game:initialize()
	self.debug = true
	self:gotoState("menu")
	self.gu = GuiUtils:new()

end

function Game:notify(message)

end

function Game:create_drawable_map(tw, th, maxX, maxY, maxZ, map)
	tw = tw or self.world.data.tile_width
	th = th or self.world.data.tile_height
	maxX = maxX or self.world.data.stats.long
	maxY = maxY or self.world.data.stats.lat
	maxZ = maxZ or self.world.data.stats.ele
	map = map or self.world.data.grid
	self.drawable_map = {}
	local dm = self.drawable_map

	for y = 1, maxY do
		for x = 1, maxX do
			local tile = map[maxZ][y][x]
			local iter = maxZ
			while tile.type == self.air_tile
				and iter > 0 do
				iter = iter-1
				tile = map[iter][y][x]
			end
			tile.x = x
			tile.y = y
			tile.z = iter
			table.insert(dm, 1, tile)
		end
	end


end

function Game:quit()

end

require'src.game_states.menu'
require'src.game_states.wb'
require'src.game_states.view_world'